//
//  AppDelegate.m
//  Demo
//
//  Created by 元元 on 2022/3/8.
//

#import "AppDelegate.h"
#import "ViewController.h"
#import "DCLoginViewController.h"
#import "DCBaseNavController.h"
#import "Adjust.h"
#import "DCTabbarViewController.h"
// or #import <Adjust/Adjust.h>
@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    
    // Use the Firebase library to configure APIs.
    UIViewController *rootVC;
    DCUserInfo *userInfo = [[CacheTools sharedCacheTools] getObjForKey:SMARTUSERINFO];
    if (userInfo) {
        DCTabbarViewController *tabbarVC = [[DCTabbarViewController alloc] init];
        rootVC = tabbarVC;
    } else {
        DCLoginViewController *vc = [[DCLoginViewController alloc]init];
        DCBaseNavController *nav = [[DCBaseNavController alloc]initWithRootViewController:vc];
        rootVC = nav;
    }
    [self.window setRootViewController:rootVC];
    [self.window makeKeyAndVisible];
    [self starSDKs];
    return YES;
}

- (void)starSDKs {
    [self starAdjust];
}

- (void)starAdjust {
    NSString *yourAppToken = AdjustToken;
    NSString *environment = ADJEnvironmentSandbox;
#ifdef DEBUG
    environment = ADJEnvironmentSandbox;
#else
    environment = ADJEnvironmentProduction;
#endif
    ADJConfig *adjustConfig = [ADJConfig configWithAppToken:yourAppToken
                                                environment:environment];
    
    [adjustConfig setLogLevel:ADJLogLevelVerbose];
    [Adjust appDidLaunch:adjustConfig];
    
}

@end
